using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Colorprj.Masters;
namespace Colorprj
{
    public partial class frmSubProduct : Form
    {
       // ProductMasterData pmd = new ProductMasterData();
        SubProductManager spm = new SubProductManager(); 

        public frmSubProduct()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            bool isValid = true;
            ////if (txtProductName.Text.Trim().Equals(""))
            ////{

            ////    MessageBox.Show("productName can not be null");
            ////    isValid = false;

            ////}
            ////if (txtProductCd.Text.Trim().Equals(""))
            ////{

            ////    MessageBox.Show("product Code can not be null");
            ////    isValid = false;

            ////}
            if (isValid)
            {
                spm.AddSubProduct(Convert.ToInt16(comboBox1.SelectedValue)  , txtName.Text,Convert.ToDecimal(   txOPBal.Text) ,Convert.ToDecimal(txtPRate.Text),Convert.ToDecimal(txtSRate.Text)  ,txtUnits.Text  );
                //this.productTableAdapter.Fill(this.colorPrjDataSet.Product);
                //dataGridView1.Refresh();  
            }  
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void frmSubProduct_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'colorPrjDataSet.Product' table. You can move, or remove it, as needed.
            this.productTableAdapter.Fill(this.colorPrjDataSet.Product);
            // TODO: This line of code loads data into the 'colorPrjDataSet2.SubProduct' table. You can move, or remove it, as needed.
            ////this.subProductTableAdapter.Fill(this.colorPrjDataSet2.SubProduct,comboBox1.SelectedValue.ToString () );
            this.subProductTableAdapter.Fill1(this.colorPrjDataSet2.SubProduct, new System.Nullable<int>(((int)(System.Convert.ChangeType(comboBox1.SelectedValue, typeof(int))))));

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //this.subProductTableAdapter.Fill(this.colorPrjDataSet2.SubProduct, comboBox1.SelectedValue.ToString());
            this.subProductTableAdapter.Fill1(this.colorPrjDataSet2.SubProduct, new System.Nullable<int>(((int)(System.Convert.ChangeType(comboBox1.SelectedValue, typeof(int))))));
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox4_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox5_TextChanged(object sender, EventArgs e)
        {

        }

        private void label6_Click(object sender, EventArgs e)
        {

        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {

        }

        ////private void fill1ToolStripButton_Click(object sender, EventArgs e)
        ////{
        ////    try
        ////    {
        ////        this.subProductTableAdapter.Fill1(this.colorPrjDataSet2.SubProduct, new System.Nullable<int>(((int)(System.Convert.ChangeType(comboBox1.SelectedValue, typeof(int))))));
        ////    }
        ////    catch (System.Exception ex)
        ////    {
        ////        System.Windows.Forms.MessageBox.Show(ex.Message);
        ////    }

        ////}
    }
}